<?php
namespace App\Http\Controllers\MobileWeb;

use App\Http\Controllers\WebController;
use App\Utils\EncryptTool;
use App\Http\Controllers\Business\App\Salesman\SalesmanManagement;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Auth;

class SalesmanController extends WebController
{
    //进入填写信息页面
    public function goToDownApp() {
        $shopId = $this->request->get('shopid');
        $shopUserId = $this->request->get('shopuserid');
        $shopName = $this->request->get('shopname');
        $data = [
            'shopid' => $shopId,
            'shopuserid' => $shopUserId,
            'shopname' => urldecode($shopName),
        ];
        if(!$shopId)
        {
            return redirect()->action('MobileWeb\MyCenterController@download');
        }
        return view('mobile.salesman.gotodown_app', $data);
    }
    //提交商家地推的手机号码
    public function submitWaitUserByShop() {
        $mobile = $this->request->get('mobile');
        $code = $this->request->get('code');
        $shopId = $this->request->get('shopid');
        $shopUserId = $this->request->get('shopuserid');
        $ip = $this->request->ip();
        $result = SalesmanManagement::addWaitUserByShop($mobile, $code, $shopId, $ip, $shopUserId);
        if($result['status'] == 'failed') {
            return $this->responseError($result['message']);
        }
        return $this->responseSuccessMessage($result['message']);
    }
    //提交用户地推的手机号码
    public function submitWaitUserByUser() {
        $mobile = $this->request->get('mobile');
        $code = $this->request->get('code');
        $userId = $this->request->get('userid');
        $ip = $this->request->ip();
        $result = SalesmanManagement::addWaitUserByUser($mobile, $code, $userId);
        if($result['status'] == 'failed') {
            return $this->responseError($result['message']);
        }
        return $this->responseSuccessMessage($result['message']);
    }
}